<template>
  <div>
    <template v-if="!acceptanceList">
      <el-empty description="无验收信息"></el-empty>
    </template>
    <template v-else>
      <el-divider>基本信息</el-divider>
      <el-descriptions direction="vertical" class="margin-top" border :column="4" size="medium">

        <el-descriptions-item label="验收标题">{{ acceptanceList.acceptanceTitle || '-' }}</el-descriptions-item>
        <el-descriptions-item label="验收人">{{ acceptanceList.newestResult && acceptanceList.newestResult.accepterName ||
            '-'
        }}
        </el-descriptions-item>
        <el-descriptions-item label="验收时间">{{ acceptanceList.newestResult && acceptanceList.newestResult.acceptanceTime
            ||
            '-'
        }}
        </el-descriptions-item>
        <el-descriptions-item label="验收类型">{{ acceptanceList.newestResult &&
            acceptanceList.newestResult.acceptanceTypeName ||
            '-'
        }}</el-descriptions-item>
        <el-descriptions-item label="前置验收类型">{{ acceptanceList.nextResult &&
            acceptanceList.nextResult.acceptanceTypeName
            ||
            '-'
        }}</el-descriptions-item>
        <el-descriptions-item label="采购申请单">{{ acceptanceList.purchaseTitle || '-' }}({{ acceptanceList.purchaseNum ||
            '-'
        }})</el-descriptions-item>
        <el-descriptions-item label="备注">{{ acceptanceList.newestResult && acceptanceList.newestResult.remark ||
            '-'
        }}</el-descriptions-item>
      </el-descriptions>
      <br>
      <el-divider>附件信息</el-divider>
      <label v-for="item in fileList" :key="item.index">
        <el-link :disabled="!item.file" icon="el-icon-document" type="primary" :href="item.file" target="_blank">
          -附件资料-</el-link>
      </label>
      <el-divider>设备信息</el-divider>
      <el-descriptions direction="vertical" class="margin-top" border :column="9" size="medium">
        <el-descriptions-item label="设备编号">{{ acceptanceList.equipmentNum || '-' }}</el-descriptions-item>
        <el-descriptions-item label="设备名称">{{ acceptanceList.equipmentName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="品牌">{{ acceptanceList.brand || '-' }}</el-descriptions-item>
        <el-descriptions-item label="规格型号">{{ acceptanceList.model || '-' }}</el-descriptions-item>
        <el-descriptions-item label="单位">{{ acceptanceList.unitName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="供应商">{{ acceptanceList.supplierName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="购置日期">{{ acceptanceList.purchaseTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="最新验收">{{ acceptanceList.newestResult &&
            acceptanceList.newestResult.acceptanceTypeName || '-'
        }}
        </el-descriptions-item>
        <el-descriptions-item label="验收时间">{{ acceptanceList.newestResult &&
            acceptanceList.newestResult.acceptanceTime || '-'
        }}</el-descriptions-item>
      </el-descriptions>
      <el-divider>验收信息</el-divider>
      <el-collapse v-model="activeName" accordion>
        <el-collapse-item v-for="(item, index) in acceptanceList.results" :key="index"
          :title="`验收人:${item.accepterName},  验收时间:${item.acceptanceTime || '-'},    验收类型 :${item.acceptanceTypeName || '-'}`"
          :name="index">
          <el-descriptions direction="vertical" class="margin_topys" border :column="3" size="medium">
            <el-descriptions-item label="验收人">{{ item.accepterName || '-' }}</el-descriptions-item>
            <el-descriptions-item label="验收时间">{{ item.acceptanceTime || '-' }}</el-descriptions-item>
            <el-descriptions-item label="验收类型">{{ item.acceptanceTypeName || '-' }}</el-descriptions-item>
            <template v-for="(value, keys) in item.acceLevelPartInfoVos">
              <el-descriptions-item label="序号">{{ keys + 1 || '-' }}</el-descriptions-item>
              <el-descriptions-item label="验收标准" :span="2">{{ value.levelName || '-' }}</el-descriptions-item>
            </template>
          </el-descriptions>
        </el-collapse-item>
      </el-collapse>
      <el-divider>验收流程</el-divider>
      <div class="accep_flex" align="center">
        <el-steps space="100px" direction="vertical" finish-status="success">
          <el-step status="success" icon="el-icon-s-help" title="采购" :description="acceptanceList.purchaseTime">
          </el-step>
          <el-step icon="el-icon-s-help" v-for="(item, index) in acceptanceList.results" :key="index"
            :status="item.status === null ? 'wait' : item.status === '0' ? 'success' : 'error'"
            :title="item.acceptanceTypeName" :description="item.accepterName + '：' + item.acceptanceTime"></el-step>
        </el-steps>
      </div>
    </template>
  </div>
</template>

<script>
import { getequipmentacceptanceList } from '@/api/equipment/equipment.js'
export default {
  name: 'acceptance',
  props: ['rowObj'],
  data () {
    return {
      total: 0,
      activeName: '',
      loading: false,
      noticeList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      acceptanceList: null,
      fileList: []//附件集合
    }
  },
  created () {
    this.getlist();
  },
  methods: {
    getlist () {
      //参数为设备台账ID
      getequipmentacceptanceList(this.rowObj.equipmentAccountId).then(res => {
        this.activeName = res.data.results.length - 1
        this.acceptanceList = res && res.data || null
        this.fileList = JSON.parse(JSON.stringify(res.data && res.data.results || []))
      })

    }
  }
}
</script>

<style lang="scss" scoped>
.margin_topys {
  margin-top: 10px;
}

.accep_flex {
  height: calc(100vh - 600px);
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>